﻿using System; 
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic; 
using System.Data;
using TimeTravel.Components;
using TimeTravel.Extentions;
using TimeTravel.IData;

namespace TimeTravel.SqlServer  
{
    //TODO:用户组逻辑代码编写

    public class SysRoleData : ISysRoleData
    {
        #region Fields

        private static readonly SqlHelper DbHelper = new SqlHelper();
        private static readonly string[] V_Columns = { "[id]", "[name]", "[descr]"};

        #endregion

        #region Implementation of IDataBase<SysRoleInfo>

        /// <summary>
        /// 添加记录
        /// </summary>
        public int Add(SysRoleInfo t)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 删除记录
        /// </summary>
        /// <param name="id"></param>
        public void Delete(int id)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 更新记录
        /// </summary>
        /// <param name="t"></param>
        public void Update(SysRoleInfo t)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        public IList<SysRoleInfo> GetAll()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 根据条件获取
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public RecordSet<SysRoleInfo> GetBySearch(PageQueryInfo query)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 获取详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public SysRoleInfo GetOne(int id)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 获取总数
        /// </summary>
        /// <returns></returns>
        public int GetTotalCount()
        {
            var strSql = new StringBuilder();
            strSql.Append("select count(id) from SysRole ");
            strSql.Append("where DeleteFlag = 0;");
            var result = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString());
            return result == null ? 0 : Convert.ToInt32(result);
        }

        #endregion

        #region BuildNavMenuObject

        /// <summary>
        /// 从DataReader中构建对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private SysRoleInfo DataReaderParser(IDataReader reader)
        {
            var sysRole = new SysRoleInfo();
            
            return sysRole;
        }

        #endregion
    }
}

